package main

import (
	"fmt"
	"gopkg.in/ini.v1"
)

const source = "my.ini"

func checkErr(err error, msg string) {
	if err != nil {
		fmt.Println(msg, err)
		return
	}
}
func SectionInfo() {
	cfg, err := ini.Load(source)
	checkErr(err, "Fail to read file:")
	sections := cfg.Sections()
	names := cfg.SectionStrings()
	fmt.Println("sections: ", sections)
	fmt.Println("names: ", names)
}
func NewSelection() {
	cfg, err := ini.Load(source)
	checkErr(err, "fail to read file: ")
	newSection := cfg.Section("new")
	fmt.Println("new section: ", newSection)
	fmt.Println("names: ", cfg.SectionStrings())
}
func ParentChildSection() {
	cfg, err := ini.Load("parent_child.ini")
	checkErr(err, "Fail to read file: ")
	fmt.Println("Clone url from package.sub:", cfg.Section("package.sub").Key("CLONE_URL").String())
}
func main() {
	ParentChildSection()
}
